package com.wlcj.www.web;

import com.alibaba.fastjson.JSON;
import com.jfinal.core.Controller;
import com.wlcj.constant.Global;
import com.wlcj.plugin.NutzPlugin;
import com.wlcj.util.Maps;

public class BaseAction extends Controller {
	
	public <T> T s(Class<T> clazz) {
		return NutzPlugin.getBean(clazz);
	}
	
	public int getUserId() {
		return getSessionAttr(Global.SESSION_LOGIN_KEY);
	}
	
	public void success(String msg) {
		renderJson(JSON.toJSONString(Maps.newHashMap("isSuccess", true, "msg", msg)));
	}
	
	public void fail(String msg) {
		renderJson(JSON.toJSONString(Maps.newHashMap("isSuccess", false, "msg", msg)));
	}

}
